package ACWing.TheNnderlyingAlgorithm.高精度;
//792. 高精度减法
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/25 10:59
 */
public class HighPrecisionSubtraction {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n=sc.next();
        String m=sc.next();
        int x=0;//表示状态
        if(!compare(n,m)){
            String s=n;
            n=m;
            m=s;
            x=1;//表示负数
        }
        if(n.equals(m)){
            System.out.println(0);
            return;
        }
        char[] char1 = n.toCharArray();
        char[] char2 = m.toCharArray();

        //将个位数放在第一位以此类推这样计算使不用考虑位数
        int[]arr=new int[Math.max(n.length(),m.length())];
        for (int i = n.length()-1,j=0; i >=0; i--,j++) {
            arr[i]=char1[j]-'0';
        }
        int[]arr2=new int[Math.max(n.length(),m.length())];
        for (int i = m.length()-1,j=0; i >=0 ; i--,j++) {
            arr2[i]=char2[j]-'0';
        }
        int t=0;
        ArrayList<Integer> list=new ArrayList();
        for (int i = 0; i < arr.length; i++) {//模拟减法借位等等
            arr[i]=arr[i]-t;
            int num=arr[i]-arr2[i];
            if(num<0){
                num=num+10;
                t=1;
                list.add(num);

            }else {
                t=0;
                list.add(num);
            }
        }
        for (int i = list.size()-1; i >=0; i--) {//处理高位0
            if(list.get(i)!=0){
                break;
            }else {
                list.remove(i);
            }
        }
        if(x==1){
            System.out.print('-');
        }

        for (int i = list.size()-1; i >=0 ; i--) {//从高位输出
            System.out.print(list.get(i));
        }
    }
    public static boolean compare(String n,String m){//比较俩位数的大小如果n大返回trie反之返回false
        if(n.length()>m.length()){
            return true;
        }else if(n.length()<m.length()){
            return false;
        }else {
            char[] chars = n.toCharArray();
            char[] chars1 = m.toCharArray();
            for (int i = 0; i < chars.length; i++) {
                if(chars[i]>chars1[i]){
                    return true;
                }else if(chars[i]<chars1[i]){
                    return false;
                }else {
                    continue;
                }
            }
        }
        return true;
    }
}
